/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 30318
 * Date: 2023-12-22
 * Time: 17:37
 */
import java.util.Scanner;

public class Administrator {//管理员系统
    private String userName;//管理员名
    private String userPWD;//密码

    public Administrator() {
    }

    public Administrator(String userName, String userPWD) {
        this.userName = userName;
        this.userPWD = userPWD;
    }

    public String getUserName() {
        return userName;
    }

    public String getUserPWD() {
        return userPWD;
    }

    public void setUserPWD(String userPWD) {
        this.userPWD = userPWD;
        System.out.println("密码修改成功！");
    }

    public boolean mateNameOrKey(String userName, String userPWD) {
        if(userName.equals(getUserName()) && userPWD.equals(getUserPWD())){
            System.out.println("成功登录！");
            return true;
        }
        else {
            System.out.println("管理员名或者密码错误！");
            return false;
        }
    }

    public boolean login() {
        Scanner in = new Scanner(System.in);
        System.out.println("*****  【满汉全席】商家端登录  *****");
        int i;
        for(i = 0;i < 3;i++) {
            System.out.println("请输入管理员账号（即用户名）：");
            String name = in.nextLine();
            System.out.println("请输入密码：");
            String password = in.nextLine();
            if(mateNameOrKey(name, password)) {
                break;
            }
            else {
                System.out.println("您还有" + (2 - i) + "次机会！");
                System.out.println("--------------------------");
            }
        }
        if(i >= 3) {
            System.out.println("对不起，您3次均输入错误！请12小时以后再试！");
            System.out.println("***********************************");
            return false;
        } else {
            return true;
        }
    }
}